package com.mjh.zhujianju.service.party.impl;

import javax.annotation.Resource;

import com.github.pagehelper.PageHelper;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.livew.framework.base.model.SysUser;
import com.livew.framework.base.service.SysUserService;
import com.livew.framework.exception.XTBusinessException;
import com.livew.framework.page.PagedBeanUtil;
import com.livew.framework.page.PagedResult;
import com.livew.framework.utils.DeleteType;
import com.livew.framework.utils.XTEntityUtils;
import com.livew.framework.utils.XTListUtils;
import com.mjh.zhujianju.model.party.*;
import com.mjh.zhujianju.service.party.*;
import com.mjh.zhujianju.util.party.ExamUtil;
import com.mjh.zhujianju.vo.party.BuildingExamAnswerVO;
import com.mjh.zhujianju.vo.party.BuildingExamResultVO;
import com.mjh.zhujianju.vo.party.BuildingExamTopicVO;
import com.mjh.zhujianju.vo.party.BuildingExamVO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.livew.framework.base.service.impl.BaseServiceImpl;
import com.mjh.zhujianju.dao.party.BuildingExamMapper;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;

import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;

/**
 * @author liuyang_admin
 */
@Service
public class BuildingExamServiceImpl extends BaseServiceImpl<BuildingExamEO> implements BuildingExamService{

	@Resource
	private BuildingExamMapper buildingExamMapper;

	@Resource
	private BuildingExamUserService buildingExamUserService;

	@Resource
	private BuildingExamResultService buildingExamResultService;

	@Resource
	private BuildingExamTopicService buildingExamTopicService;

	@Autowired
	private BuildingExamAnswerService buildingExamAnswerService;

	@Autowired
	private SysUserService sysUserService;


	@Autowired
	private ExamUtil examUtil;
	
	public BuildingExamServiceImpl(BuildingExamMapper buildingExamMapper) {
		super(buildingExamMapper);
	}

	@Override
	public List<BuildingExamVO> queryBuildingExamForWXList() {
		List<BuildingExamVO> list = Lists.newArrayList();

		//查询试题
		List<BuildingExamEO> buildingExamEOList = buildingExamMapper.selectAll();
		if (CollectionUtils.isEmpty(buildingExamEOList)){
			return list;
		}

		BuildingExamVO buildingExamVO;
		for (BuildingExamEO buildingExamEO : buildingExamEOList){
			buildingExamVO = new BuildingExamVO();
			BeanUtils.copyProperties(buildingExamEO,buildingExamVO);
			list.add(buildingExamVO);
		}

		//统计参与人数
		List<BuildingExamResultVO> buildingExamResultVOList = buildingExamResultService.selectTotalUsers();
		if (CollectionUtils.isEmpty(buildingExamResultVOList)){
			return list;
		}

		//组装
		initExamList(list,buildingExamResultVOList);
		return list;
	}

	private void initExamList(List<BuildingExamVO> list,List<BuildingExamResultVO> buildingExamResultVOList){
         //组装
		for (BuildingExamVO buildingExam : list){
			for (BuildingExamResultVO buildingExamResultVO : buildingExamResultVOList){
				if (buildingExam.getId().equals(buildingExamResultVO.getExamId())){
					buildingExam.setTotalJoinUsers(buildingExamResultVO.getTotalUsers());
					continue;
				}
			}
		}
	}

	@Override
	public List<BuildingExamVO> queryBuildingExamByUserIdList(Long userId) {
		List<BuildingExamResultEO> buildingExamResultEOList = buildingExamResultService.queryBuildingExamResultByUserIdList(userId);
		if (CollectionUtils.isEmpty(buildingExamResultEOList)){
			return null;
		}

		List<Long> examIds = buildingExamResultEOList.stream().map(buildingExamResultEO -> buildingExamResultEO.getExamId()).distinct().collect(Collectors.toList());

		List<BuildingExamEO> buildingExamEOList = buildingExamMapper.selectByIdList(examIds);

		List<BuildingExamVO> list = Lists.newArrayList();

		BuildingExamVO buildingExamVO;
		for (BuildingExamEO buildingExamEO : buildingExamEOList){
			buildingExamVO = new BuildingExamVO();
			BeanUtils.copyProperties(buildingExamEO,buildingExamVO);

			for (BuildingExamResultEO buildingExamResultEO : buildingExamResultEOList){
				if (buildingExamEO.getId().equals(buildingExamResultEO.getExamId())){
					buildingExamVO.setResultId(buildingExamResultEO.getId());
					continue;
				}
			}
			list.add(buildingExamVO);
		}

		//统计参与人数
		List<BuildingExamResultVO> buildingExamResultVOList = buildingExamResultService.selectTotalUsers();
		if (CollectionUtils.isEmpty(buildingExamResultVOList)){
			return list;
		}

		//组装
		initExamList(list,buildingExamResultVOList);
		return list;
	}

	@Override
	public Map<String,Object> addExamUser(BuildingExamVO buildingExamVO) throws XTBusinessException {
		//查询用户考试记录
		Map<Long,List<Long>> map = Maps.newHashMap();
		List<Long> ids;
		//循环题目
		for (BuildingExamTopicVO vo : buildingExamVO.getBuildingExamTopicVOS()){
			ids = Lists.newArrayList();
			//循环题目内容
			for (BuildingExamAnswerEO answerEO : vo.getBuildingExamAnswerEOList()){
				//当前用户选择的题目
				if (answerEO.getStatus().equals("1")){
					ids.add(answerEO.getId());
				}
			}
			map.put(vo.getId(),ids);
		}

		Long examId = buildingExamVO.getBuildingExamTopicVOS().get(0).getExamId();
		BuildingExamEO eo = buildingExamMapper.selectByPrimaryKey(examId);
		long newDate = System.currentTimeMillis();
		long old = Long.valueOf(buildingExamVO.getTestTime());
		String str = examUtil.getDistanceTime(newDate,old);
		System.out.println("....................str:"+str);

		//1-添加考试结果
		BuildingExamResultEO buildingExamResultEO = new BuildingExamResultEO();
		buildingExamResultEO.setTestTime(str);
		buildingExamResultEO.setExamId(examId);
		buildingExamResultEO.setUserId(buildingExamVO.getUserId());
		buildingExamResultService.save(buildingExamResultEO);

		//2-批量添加用户答题记录
		buildingExamUserService.insertByBatch(map,buildingExamResultEO.getId());

		//3-查询当前课题正确答案
		List<BuildingExamTopicVO> buildingExamTopicVOList = buildingExamTopicService.selectTopicAnswers(examId);

		Integer totalGrade = 0 ;
		Map<Long,String> resMap = Maps.newHashMap();
		Long count = 1L;

        //3-算成绩
		for (BuildingExamTopicVO vo : buildingExamVO.getBuildingExamTopicVOS()){
			String ischeck = "false";

			if (!vo.getType().equals("2")){
				//单选+判断
				boolean isAnswer=false;
				//循环题目内容
				for (BuildingExamAnswerEO answerEO : vo.getBuildingExamAnswerEOList()){
					//当前用户选择的题目
					if (answerEO.getStatus().equals("0")&&answerEO.getIsAnswer().equals("1")){
						isAnswer=true;
						continue;
					}
				}
				if (isAnswer){
					totalGrade = totalGrade +vo.getGrade();
					ischeck = "true";
				}
			}else {
				//多选
				boolean isAnswer=true;
				//循环题目内容
				for (BuildingExamAnswerEO answerEO : vo.getBuildingExamAnswerEOList()){
					//当前是正确 答案 && 用户没有选择 == 本题0分
					if (answerEO.getIsAnswer().equals("0")&&!answerEO.getStatus().equals("1")){
						isAnswer=false;
						continue;
					}
				}
				if (isAnswer){
					totalGrade = totalGrade +vo.getGrade();
					ischeck = "true";
				}
			}
			resMap.put(count,ischeck);
			count++;
		}

		//4-归档
		//考试科目信息
		BuildingExamEO buildingExamEO = buildingExamMapper.selectByPrimaryKey(examId);
		buildingExamResultEO.setTestScore(totalGrade);
		//0-通过,1-不通过
		if (totalGrade >= buildingExamEO.getPassingGrade()){
			buildingExamResultEO.setStatus("0");
		}else {
			buildingExamResultEO.setStatus("1");
		}

		buildingExamResultEO.setUpdateTime(new Date());
		buildingExamResultService.updateByPrimaryKey(buildingExamResultEO);


		//5-整理
		Map<String,Object> res = Maps.newHashMap();

		//考试得分
		res.put("grade",totalGrade);

		//及格分
		res.put("passingGrade",buildingExamEO.getPassingGrade());

		//是否通过：0-通过，1-不通过
		res.put("isPass",buildingExamResultEO.getStatus());

		//考试用时
		res.put("testTime",buildingExamResultEO.getTestTime());

		//改卷结果
		res.put("resMap",resMap);

		res.put("title",eo.getName());

		res.put("resultId",buildingExamResultEO.getId());
		res.put("examId",examId);
		return res;
	}

	@Override
	public PagedResult<BuildingExamVO> findBuildingExamPagination(BuildingExamEO buildingExamEO) {
		Integer pageNo = buildingExamEO.getPageNo() == null ? 1 : buildingExamEO.getPageNo();
		Integer pageSize = buildingExamEO.getPageSize() == null ? 15 : buildingExamEO.getPageSize();
		PageHelper.startPage(pageNo, pageSize);
		List<BuildingExamEO> list = buildingExamMapper.selectPagination(buildingExamEO);
		PagedResult<BuildingExamEO> page = PagedBeanUtil.toPagedResult(list);
		PagedResult<BuildingExamVO> result = new PagedResult<BuildingExamVO>();
		BeanUtils.copyProperties(page, result);
//		if (!XTListUtils.isEmpty(list)) {
//			List<Long> ids = XTEntityUtils.getIdList(list);
//			List<BuildingEventVO> voList = new ArrayList<BuildingEventVO>();
////            Map<Long, FileEO> files = fileService.getMapTopOne(ids, BuildingClassEO.class.getName(), null);
//			Map<Long,Long> joinUsersMap = buildingEventUsersService.getMapTopOne(ids);
//			for (BuildingEventEO buildingEventEO1 : list) {
//				BuildingEventVO d = new BuildingEventVO();
//				BeanUtils.copyProperties(buildingEventEO1, d);
//				voList.add(d);
//				Long joinUsers = joinUsersMap.get(d.getId());
//				if(joinUsers != null){
//					d.setJoinUsers(joinUsers.intValue());
//				}else {
//					d.setJoinUsers(0);
//				}
//			}
//			result.setDataList(voList);
//		}
		return result;
	}

	@Override
	public PagedResult<BuildingExamTopicVO> findBuildingExamTopicPagination(BuildingExamTopicEO buildingExamTopicEO) {
		Integer pageNo = buildingExamTopicEO.getPageNo() == null ? 1 : buildingExamTopicEO.getPageNo();
		Integer pageSize = buildingExamTopicEO.getPageSize() == null ? 15 : buildingExamTopicEO.getPageSize();
		PageHelper.startPage(pageNo, pageSize);
		List<BuildingExamTopicEO> list = buildingExamTopicService.selectPagination(buildingExamTopicEO);
		PagedResult<BuildingExamTopicEO> page = PagedBeanUtil.toPagedResult(list);
		PagedResult<BuildingExamTopicVO> result = new PagedResult<BuildingExamTopicVO>();
		BeanUtils.copyProperties(page, result);
		return result;
	}

	@Override
	public Long saveInfo(BuildingExamVO buildingExamVO) throws XTBusinessException {
		BuildingExamEO buildingExamEO = new BuildingExamEO();
		BeanUtils.copyProperties(buildingExamVO, buildingExamEO);
		if (StringUtils.isEmpty(buildingExamEO.getId())) {
			this.save(buildingExamEO);

		} else {
			this.updateByPrimaryKey(buildingExamEO);
		}

		return buildingExamEO.getId();
	}

	@Override
	public void saveInfo(BuildingExamTopicVO buildingExamTopicVO) throws XTBusinessException {
		if (StringUtils.isEmpty(buildingExamTopicVO.getId())) {
			buildingExamTopicService.save(buildingExamTopicVO);
			if(!CollectionUtils.isEmpty(buildingExamTopicVO.getBuildingExamAnswerEOList())){
				for(BuildingExamAnswerEO buildingExamAnswerEO : buildingExamTopicVO.getBuildingExamAnswerEOList()){
					buildingExamAnswerEO.setTopicId(buildingExamTopicVO.getId());
				}

				buildingExamAnswerService.batchSaveAnswers(buildingExamTopicVO.getBuildingExamAnswerEOList());

			}
		} else {
			buildingExamTopicService.updateByPrimaryKey(buildingExamTopicVO);
			buildingExamAnswerService.deleteByTopicId(buildingExamTopicVO.getId());
			if(!CollectionUtils.isEmpty(buildingExamTopicVO.getBuildingExamAnswerEOList())){
				for(BuildingExamAnswerEO buildingExamAnswerEO : buildingExamTopicVO.getBuildingExamAnswerEOList()){
					buildingExamAnswerEO.setTopicId(buildingExamTopicVO.getId());
				}
				buildingExamAnswerService.batchSaveAnswers(buildingExamTopicVO.getBuildingExamAnswerEOList());
			}

		}

	}

	@Override
	public BuildingExamVO queryBuildingExamInfo(Long id) {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
		BuildingExamVO buildingExamVO = new BuildingExamVO();
		BuildingExamEO buildingExamEO = buildingExamMapper.selectByPrimaryKey(id);
		if (buildingExamEO == null){
			return buildingExamVO;
		}
		buildingExamVO.setStartTimeStr(sdf.format(buildingExamEO.getStartTime()));
		buildingExamVO.setEndTimeStr(sdf.format(buildingExamEO.getEndTime()));
		BeanUtils.copyProperties(buildingExamEO,buildingExamVO);
		return buildingExamVO;
	}

	@Override
	public BuildingExamTopicVO queryBuildingExamTopicInfo(Long id) {
		BuildingExamTopicEO buildingExamTopicEO = buildingExamTopicService.selectTpoicInfo(id);
		if(buildingExamTopicEO != null){
			BuildingExamTopicVO buildingExamTopicVO = new BuildingExamTopicVO();
			BeanUtils.copyProperties(buildingExamTopicEO,buildingExamTopicVO);
			//根据topicId查询试题选项
			List<BuildingExamAnswerEO> buildingExamAnswerEOS = buildingExamAnswerService.findTopicAnswers(id);
			if(!CollectionUtils.isEmpty(buildingExamAnswerEOS)){
				buildingExamTopicVO.setBuildingExamAnswerEOList(buildingExamAnswerEOS);
			}

			return buildingExamTopicVO;
		}

		return null;
	}

	@Override
	public void delTopicByPrimaryKey(Long id) throws XTBusinessException {
		BuildingExamTopicEO buildingExamTopicEO = new BuildingExamTopicEO();
		buildingExamTopicEO.setId(id);
		buildingExamTopicService.delByPrimaryKey(buildingExamTopicEO);
	}

	/**
	 * 根据examId返回所有试题以及试题答案
	 * @param id
	 * @return
	 */
	@Override
	public BuildingExamVO findBuildingExamInfo(Long id) {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
		Map<Long,List<BuildingExamAnswerEO>> answerMap = null;
		//查询考试信息
		BuildingExamEO buildingExamEO = buildingExamMapper.selectByPrimaryKey(id);

		//查询考试下所有试题
		List<BuildingExamTopicEO> buildingExamTopicEOS = buildingExamTopicService.findBuildingExamTopicByExamId(id);
		if(!CollectionUtils.isEmpty(buildingExamTopicEOS)){
			List<Long> ids = buildingExamTopicEOS.stream().map(buildingExamTopicEO -> buildingExamTopicEO.getId()).distinct().collect(Collectors.toList());
			List<BuildingExamAnswerEO> buildingExamAnswerEOS = buildingExamAnswerService.queryBuildingExamAnswerByTopicIds(ids);

			if(!CollectionUtils.isEmpty(buildingExamAnswerEOS)){
				answerMap = new HashMap<Long,List<BuildingExamAnswerEO>>();
				for(BuildingExamAnswerEO buildingExamAnswerEO : buildingExamAnswerEOS){
					if(answerMap.get(buildingExamAnswerEO.getTopicId()) == null){
						List<BuildingExamAnswerEO> buildingExamAnswerEOS1 = new ArrayList<BuildingExamAnswerEO>();
						buildingExamAnswerEOS1.add(buildingExamAnswerEO);
						answerMap.put(buildingExamAnswerEO.getTopicId(),buildingExamAnswerEOS1);
					}else {
						List<BuildingExamAnswerEO> buildingExamAnswerEOS1 = answerMap.get(buildingExamAnswerEO.getTopicId());
						buildingExamAnswerEOS1.add(buildingExamAnswerEO);
					}
				}
			}

			List<BuildingExamTopicVO> buildingExamTopicVOS = new ArrayList<BuildingExamTopicVO>();
			for(BuildingExamTopicEO buildingExamTopicEO :buildingExamTopicEOS){
				List<BuildingExamAnswerEO> buildingExamAnswerEOS1 = answerMap.get(buildingExamTopicEO.getId());
				if(!CollectionUtils.isEmpty(buildingExamAnswerEOS1)){
					BuildingExamTopicVO buildingExamTopicVO = new BuildingExamTopicVO();
					BeanUtils.copyProperties(buildingExamTopicEO,buildingExamTopicVO);
					Collections.sort(buildingExamAnswerEOS1);
					buildingExamTopicVO.setBuildingExamAnswerEOList(buildingExamAnswerEOS1);
					StringBuilder sb = new StringBuilder();
					for(BuildingExamAnswerEO buildingExamAnswerEO : buildingExamAnswerEOS1){
						if("0".equals(buildingExamAnswerEO.getIsAnswer())){
							sb.append(buildingExamAnswerEO.getSort());
							sb.append(",");
						}
					}
					String temp = sb.toString();
					if(!StringUtils.isEmpty(temp)){
						buildingExamTopicVO.setSort(temp.substring(0,temp.length()-1));
					}

					buildingExamTopicVOS.add(buildingExamTopicVO);

				}
			}

			BuildingExamVO buildingExamVO = new BuildingExamVO();
			BeanUtils.copyProperties(buildingExamEO,buildingExamVO);

			Long interval = buildingExamVO.getEndTime().getTime() - buildingExamVO.getStartTime().getTime();
			buildingExamVO.setTimeInterval(interval/(1000*60));
			buildingExamVO.setStartTimeStr(sdf.format(buildingExamVO.getStartTime()));
			buildingExamVO.setEndTimeStr(sdf.format(buildingExamVO.getEndTime()));
			buildingExamVO.setBuildingExamTopicVOS(buildingExamTopicVOS);
			return buildingExamVO;
		}
		return null;
	}

	@Override
	public BuildingExamVO findPersonalBuildingExamInfo(Long examId, Long resultId) throws XTBusinessException {
		//查询试题信息
		BuildingExamVO buildingExamVO = this.findBuildingExamInfo(examId);
		//查询结果信息
		BuildingExamResultEO buildingExamResultEO = buildingExamResultService.getByPrimaryKey(resultId);
		BuildingExamResultVO buildingExamResultVO = new BuildingExamResultVO();
		BeanUtils.copyProperties(buildingExamResultEO,buildingExamResultVO);
		SysUser sysUser = sysUserService.getByPrimaryKey(buildingExamResultEO.getUserId());
		if(sysUser != null){
			buildingExamResultVO.setUserName(sysUser.getNickname());
		}
		//查询答题明细
		//查询当前考试正确答案
		List<BuildingExamTopicVO> buildingExamTopicVOList = buildingExamTopicService.selectTopicAnswers(examId);
		//查询当前用户的答案
		List<BuildingExamUserEO> buildingExamUserEOS= buildingExamUserService.queryBuildingExamUserByResultId(resultId);
		Map<Long,List<Long>> userAnswers = null;
		List<Long> longList = null;
		if(!CollectionUtils.isEmpty(buildingExamUserEOS)){
			userAnswers = new HashMap<Long,List<Long>>();
			for(BuildingExamUserEO buildingExamUserEO:buildingExamUserEOS){
				if(userAnswers.containsKey(buildingExamUserEO.getTopicId())){
					longList = userAnswers.get(buildingExamUserEO.getTopicId());
					longList.add(buildingExamUserEO.getAnswerId());
					userAnswers.put(buildingExamUserEO.getTopicId(),longList);
				}else {
					longList = new ArrayList<Long>();
					longList.add(buildingExamUserEO.getAnswerId());
					userAnswers.put(buildingExamUserEO.getTopicId(),longList);
				}

			}

			Map<String,Integer> map = examUtil.analysisuserResult(buildingExamTopicVOList,userAnswers);
			buildingExamResultVO.setPassed(map.get("passed"));
			buildingExamResultVO.setUnpassed(map.get("unpassed"));
		}

		//处理用户选择的答案项目，选择了则前台显示√
		if(!CollectionUtils.isEmpty(buildingExamVO.getBuildingExamTopicVOS())){
			for(BuildingExamTopicVO buildingExamTopicVO :buildingExamVO.getBuildingExamTopicVOS()){
				if(!CollectionUtils.isEmpty(buildingExamTopicVO.getBuildingExamAnswerEOList())){
					List<BuildingExamAnswerVO> buildingExamAnswerVOS = new ArrayList<BuildingExamAnswerVO>();
					for(BuildingExamAnswerEO buildingExamAnswerEO : buildingExamTopicVO.getBuildingExamAnswerEOList()){
						BuildingExamAnswerVO buildingExamAnswerVO = new BuildingExamAnswerVO();
						BeanUtils.copyProperties(buildingExamAnswerEO,buildingExamAnswerVO);
						if(userAnswers.containsKey(buildingExamTopicVO.getId())){
							List<Long> answers = userAnswers.get(buildingExamTopicVO.getId());
							if(answers.contains(buildingExamAnswerVO.getId())){
								buildingExamAnswerVO.setChoosed(1);

							}
						}
						buildingExamAnswerVOS.add(buildingExamAnswerVO);
					}
					buildingExamTopicVO.setBuildingExamAnswerVOS(buildingExamAnswerVOS);
				}
			}
		}
		buildingExamVO.setBuildingExamResultVO(buildingExamResultVO);
		return buildingExamVO;
	}

	@Override
	public BuildingExamVO findBuildingExamResultInfo(BuildingExamVO buildingExamVO) {
		BuildingExamVO buildingExamVO1 = new BuildingExamVO();
		int totalCount = 0;
		int passed = 0;
		int unpassed = 0;

		Integer pageNo = buildingExamVO.getPageNo() == null ? 1 : buildingExamVO.getPageNo();
		Integer pageSize = buildingExamVO.getPageSize() == null ? 15 : buildingExamVO.getPageSize();
		PageHelper.startPage(pageNo, pageSize);
		List<BuildingExamResultEO> list = buildingExamResultService.queryBuildingExamResultByExamId(buildingExamVO.getId());
		if(!CollectionUtils.isEmpty(list)){
			List<Long> ids = list.stream().map(buildingExamResultEO -> buildingExamResultEO.getUserId()).distinct().collect(Collectors.toList());
			Map<Long,SysUser> sysUserMap = sysUserService.getMapTopOne(ids);
			//计算考试人数、通过人数、未通过人数、平均分
			List<BuildingExamResultVO> buildingExamResultVOS = new ArrayList<BuildingExamResultVO>();
			BuildingExamResultVO buildingExamResultVO = null;
			for(BuildingExamResultEO buildingExamResultEO : list){
				buildingExamResultVO = new BuildingExamResultVO();
				BeanUtils.copyProperties(buildingExamResultEO,buildingExamResultVO);
				SysUser sysUser = sysUserMap.get(buildingExamResultEO.getUserId());
				if(sysUser != null){
					buildingExamResultVO.setUserName(sysUser.getNickname());
				}
				totalCount += buildingExamResultEO.getTestScore();

				if("0".equals(buildingExamResultEO.getStatus())){
					passed++;
				}else {
					unpassed++;
				}

				buildingExamResultVOS.add(buildingExamResultVO);
			}
			buildingExamVO1.setTotalJoinUsers(list.size());
			buildingExamVO1.setPassedUsers(passed);
			buildingExamVO1.setUnpassedUsers(unpassed);
			buildingExamVO1.setAvgCounts(totalCount/list.size());
			PagedResult<BuildingExamResultVO> page = PagedBeanUtil.toPagedResult(buildingExamResultVOS);
			buildingExamVO1.setPagedResult(page);
			return buildingExamVO1;
		}

		return null;
	}

}
